//
//  MOGetMarriedListEditOrCreatViewCell.m
//  MobileOffice
//
//  Created by 冰冰 on 2019/8/16.
//  Copyright © 2019 com.idolmedia. All rights reserved.
//

#import "MOGetMarriedListEditOrCreatViewCell.h"

@interface MOGetMarriedListEditOrCreatViewCell ()<UITextFieldDelegate>

@property(nonatomic,strong)UILabel *nameLabel;

@property(nonatomic,strong)UITextField *textField;

@end

@implementation MOGetMarriedListEditOrCreatViewCell

+(instancetype)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath
{
    //NSString *ID = [NSString stringWithFormat:@"Cell%ld%ld",(long)[indexPath section],(long)[indexPath row]];
    NSString *ID = @"MOGetMarriedListEditOrCreatViewCell";
    MOGetMarriedListEditOrCreatViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil){
        cell = [[MOGetMarriedListEditOrCreatViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        [cell creatView];
    }
    return cell;
}


-(void)creatView
{
    self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 0, 1, kHConversions(54))];
    self.nameLabel.textColor = KBlackColor_222222;
    self.nameLabel.font = [UIFont boldSystemFontOfSize:15];
    [self addSubview:self.nameLabel];
    
    self.textField = [[UITextField alloc]initWithFrame:CGRectMake(0, 0, 1, kHConversions(54))];
    self.textField.delegate = self;
    self.textField.textColor = KBlackColor_222222;
    self.textField.font = FONT_SIZE(15);
    [self addSubview:self.textField];
}

-(void)setModel:(MOGetMarriedListEditOrCreatModel *)model
{
    self.nameLabel.text = model.nameStr;
    
    self.textField.placeholder = model.placeStr;
    
    self.textField.text = model.valueStr;
    
    self.textField.keyboardType = [model.keyBoardType integerValue];
    
    self.nameLabel.width = model.nameLabelWidth;
    
    self.textField.x = self.nameLabel.right + 20;
    self.textField.width = SCREEN_WIDTH - 30 - model.nameLabelWidth - 20;
}

-(void)textFieldDidEndEditing:(UITextField *)textField
{
    if (self.textFieldEndEditingBlock) {
        self.textFieldEndEditingBlock(textField.text);
    }
}

@end
